package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class DVDCollection here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DVDCollection
{
    // instance variables - replace the example below with your own
    private ArrayList<DVD> dvd;

    /**
     * Constructor for objects of class DVDCollection
     */
    public DVDCollection()
    {

        dvd = new ArrayList<DVD>();

    }

    /**
     * this method adds DVD's to the collection
     * @param dvd
     */
    public void addDVD(DVD dvd)
    {
        this.dvd.add(dvd);
    }

    /**
     * this method removes a DVD from the collection
     * @param title
     */
    public void deleteDVD(String title)
    {
        DVD d = findDVD(title);
        this.dvd.remove(d);
    }

    /**
     * this method makes it possible to search for DVD's in the collection
     * @param title
     * @return null or dvds
     */
    public DVD findDVD(String title)
    {
        int index = 0;
        while(dvd.size() > index)
        {
            DVD dvds = dvd.get(index);
            if(dvds.getTitle().contains(title))
            {
                return dvds;
            }
            index++;
        }
        return null;
    }

    /**
     * this method creates a copy object that can be used in the DVDCtr
     * @param ID, serialNo, purchaseDate, purchasePrice
     */
    // this method can not compile, is to be rewritten. for now it is not possible to create a
    // from the DVDUI      
    public void createCopy(int ID, String serialNo, int purchaseDate, double purchasePrice)
    {
        Copy copy = new Copy(serialNo, purchaseDate, purchasePrice);
        dvd.addCopy(copy);
    }

    /**
     * this method returns the list of DVD's
     * @return dvd
     */
    public ArrayList<DVD> listAllDVDs()
    {
        return dvd;
    }

   
}
